﻿
<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <title>{{ conf['NAME'] }}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="{{ conf['NAME'] }}">
	<meta name="keywords" content="">
	<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.4/css/bootstrap.min.css">
	<link href="http://cdn.bootcss.com/highlight.js/8.6/styles/monokai_sublime.min.css" rel="stylesheet">
	{% block style %}{% end %}
	<style>
	body{font-family:"ff-tisa-web-pro-1","ff-tisa-web-pro-2","Lucida Grande","Helvetica Neue",Helvetica,Arial,"Hiragino Sans GB","Hiragino Sans GB W3","Microsoft YaHei UI","Microsoft YaHei","WenQuanYi Micro Hei",sans-serif;}
	</style>
	<style>
		.w90{width:90%;margin-left: auto;margin-right: auto;}
		.w60{width:60%;margin-left: auto;margin-right: auto;}
		.w35{width:35%;margin-left: auto;margin-right: auto;}
	</style>
    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
	  <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

    <!-- Le fav and touch icons -->
  </head>

  <body data-spy="scroll" data-target=".bs-docs-sidebar">
  {% raw xsrf_form_html() %}
  <DIV CLASS="w90">
  <h1>{{ conf['NAME'] }} </h1>
  <p class="lead">{{ conf['Subtitle'] }}</p>
  </DIV>
		<div class="navbar navbar-inverse w90">
			<div class="navbar-inner">
				<div class="container">
					<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
						<span class="icon-bar"></span>
						<span class="icon-bar"></span>
						<span class="icon-bar"></span>
					</a>
					<a class="navbar-brand" href="index.html">Home</a>
					<ul class="nav navbar-nav" id="nav">
					<li><a href="/admin">文章管理</a></li>
					<li><a href="#" data-toggle="modal" data-target="#config">博客设定</a></li>
					<li><a href="#" data-toggle="modal" data-target="#user">用戶管理</a></li>
					<li><a href="/custom">自定义内容管理</a></li>
					<li><a href="/generate">更新整站静态文件</a></li>
					</ul>
					<ul class="nav navbar-nav navbar-right">
					<li><a href="logout">登出</a></li>
					</ul>
				</div>
			</div>
		</div>
<!-- config-->
<div class="modal fade" id="config" tabindex="-1" role="dialog" aria-labelledby="NewModal" aria-hidden="true">
  <div class="modal-dialog w35">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="add"><b>博客信息设定：</b></h4>
      </div>
      <div class="modal-body">
        <div class="form-group">
		<table class="w90">
			<tr><td>博客名称:</td><td><input type="text" class="form-control" id='bkname' value="{{ conf['NAME'] }}"></td></tr>
			<tr><td>副标题</td><td><input type="text" class="form-control" id='Subtitle' value="{{ conf['Subtitle'] }}"></td></tr>
			<tr><td>博客描述</td><td><input type="text" class="form-control" id='description' value="{{ conf['description']}}"></td></tr>
			<tr><td>关键字</td><td><input type="text" class="form-control" id='keywords' value="{{ conf['keywords']}}"></td></tr>
		</table>
	    </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
        <button type="button" id="update" class="btn btn-primary">提交</button>
      </div>
    </div>
  </div>
</div>
<!-- usermanager-->
<div class="modal fade" id="user" tabindex="-1" role="dialog" aria-labelledby="NewModal" aria-hidden="true">
  <div class="modal-dialog w35">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="add"><b>用戶设定：</b></h4>
      </div>
      <div class="modal-body">
        <div class="form-group">
		<table class="w90">
			<tr><td>用户名:</td><td><input type="text" class="form-control" id='newuser'></td></tr>
			<tr><td>旧密码:</td><td><input type="password" class="form-control" id='oldpwd'></td></tr>
			<tr><td>新密碼：</td><td><input type="password" class="form-control" id='pwd1'></td></tr>
			<tr><td>確認輸入</td><td><input type="password" class="form-control" id='pwd2'></td></tr>
		</table>
	    </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
        <button type="button" id="userupdate" class="btn btn-primary">提交</button>
      </div>
    </div>
  </div>
</div>

{% block body %}{% end %}
<script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://cdn.bootcss.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script src="http://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
{% block js %}{% end %}
<script>
var xsrf=$.cookie("_xsrf")
$("#update").click(function(){
	if ($("#bkname").val()=="" ||  $("#Subtitle").val()=="" || $("#description").val()=="" || $("#keywords").val()=="") { alert("抱歉，有项目为空！")}
	else {
		$.post("update",{bkname:$("#bkname").val(),
						subtitle:$("#Subtitle").val(),
						description:$("#description").val(),
						keywords:$("#keywords").val(),
						_xsrf:xsrf},function(date){
			if (date=="0"){location.reload();}
			else {alert("设定更新失败，请确认后端服务是否正常！")}
			})
	}
	})
$("#userupdate").click(function(){
	if ($("#newuser").val()=="" ||  $("#oldpwd").val()=="" || $("#pwd1").val()=="" || $("#pwd2").val()=="") { alert("抱歉，有项目为空！")}
	else  if($("#pwd1").val()==$("#pwd2").val()){
		$.post("userupdate",{username:$("#newuser").val(),
						oldpwd:$("#oldpwd").val(),
						pwd1:$("#pwd1").val(),
						pwd2:$("#pwd2").val(),
						_xsrf:xsrf},function(date){
			if (date=="0"){window.location.href="/logout"}
			else {alert(data)}
			})} else{alert("两次密码输入不一致！")}
	})
</script>

</body>
</html>